﻿using UnityEngine;
using System.Collections;
using System.IO;
using Mono.Data.Sqlite;

public class Database : MonoBehaviour {


	/// <summary>
    /// SQLite数据库辅助类
    /// </summary>
    public SQLiteHelper sql;


	//private string appDBPath = Application.dataPath  + "/xuanyusong.db";
	protected static Database instance;
	public static Database Instance
    {
        get
        {
            if (instance == null)
            {
                instance = (Database)FindObjectOfType(typeof(Database));
            }
            return instance;
        }
    }



    void Start () 
    {
    	string appDBPath = Application.dataPath  + "/braves.db";
		Instance.sql = new SQLiteHelper(@"Data Source=" + appDBPath);

        //创建名为item的数据表
        // Instance.sql.CreateTable("item",
        //     new string[]{"ID",     "Name","Num",    "Note"},
        //     new string[]{"INTEGER","TEXT","INTEGER","TEXT"});

        // Instance.sql.CreateTable("skill",
        //     new string[]{"ID",     "cd_time","attack_distance","auto_use","direct_dmg","direct_treat","factor_dmg","factor_treat"},
        //     new string[]{"INTEGER","INTEGER","INTEGER",        "INTEGER", "INTEGER",   "INTEGER",     "INTEGER",   "INTEGER"});

        //关闭数据库连接
        //Instance.sql.CloseConnection();
    }
	
	// Update is called once per frame
	void Update () {
	
	}
}
